'use strict';
/**
 * CarController
 * @constructor
 */
app.controller('TaskController',['$scope','$http',function($scope, $http){
	$scope.fetchCarsList = function() {
        $http.get('process/task/todoTasks').success(function(datas){
            $scope.datas = datas;
        });
    };
    
    $scope.claim = function(taskId){
 
    	$http.post('process/task/claim?taskId='+taskId).success(function() {
            $scope.fetchCarsList();
           
        }).error(function() {
           
        });
    }
    $scope.fetchCarsList();
}]);
app.controller('ProcessTaskCtrl', ['$scope',  '$stateParams','$http',function($scope,  $stateParams,$http) {
	
	
	$http.get('process/task/getForm?taskId='+$stateParams.taskId).success(function(datas){
        $scope.datas = datas;
    });
	$http.get('process/task/getFormValue?taskId='+$stateParams.taskId).success(function(datas){
        $scope.param = datas;
    });
	$scope.complete = function(task) {
        $http.post('process/task/complete', JSON.stringify(task)).success(function() {
           
           
        }).error(function() {
            $scope.setError('Could not add a new train');
        });
    };
	}]);
